package com.securities.stock;

import com.securities.stock.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import tk.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@MapperScan(value = "com.securities.stock.mapper")
@ImportResource(locations={"classpath:applicationContext-scheduler.xml"})
public class StockApp {

    public static void main(String[] args) {
        SpringApplication.run(StockApp.class, args);
    }

    @Bean
    public RestTemplate getRestTemplate(){
        return  new RestTemplate();
    }
    @Service
    public static class  MyInitStart5 implements CommandLineRunner {
        @Autowired
        private StockService stockService;
        @Override
        public void run(String... args) {
            stockService.initAllStcok();
        }
    }
}
